<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Upgrade iRedMail from 0.8.3 to 0.8.4</title>
        <link rel="stylesheet" type="text/css" href="./css/markdown.css" />
    </head>
    <body>

    <div id="navigation">
    <a href="https://www.iredmail.org" target="_blank">
        <img alt="iRedMail web site"
             src="./images/logo-iredmail.png"
             style="vertical-align: middle; height: 30px;"
             />&nbsp;
        <span>iRedMail</span>
    </a>
    &nbsp;&nbsp;//&nbsp;&nbsp;<a href="./index.html">Document Index</a></div><h1 id="upgrade-iredmail-from-083-to-084">Upgrade iRedMail from 0.8.3 to 0.8.4</h1>
<div class="admonition attention">
<p class="admonition-title">Attention</p>
<p>Check out the lightweight on-premises email archiving software developed by iRedMail team: <a href="https://spiderd.io/">Spider Email Archiver</a>.</p>
</div>
<div class="toc">
<ul>
<li><a href="#upgrade-iredmail-from-083-to-084">Upgrade iRedMail from 0.8.3 to 0.8.4</a><ul>
<li><a href="#changelog">ChangeLog</a></li>
<li><a href="#general-all-backends-should-apply-these-steps">General (All backends should apply these steps)</a><ul>
<li><a href="#update-etciredmail-release-with-iredmail-version-number">Update /etc/iredmail-release with iRedMail version number</a></li>
<li><a href="#upgrade-roundcube-webmail-to-the-latest-stable-release">Upgrade Roundcube webmail to the latest stable release</a></li>
<li><a href="#upgrade-iredapd-postfix-policy-server-to-the-latest-stable-release">Upgrade iRedAPD (Postfix policy server) to the latest stable release</a></li>
<li><a href="#upgrade-iredadmin-open-source-edition-to-the-latest-stable-release">Upgrade iRedAdmin (open source edition) to the latest stable release</a></li>
<li><a href="#add-new-alias-virusalert-in-postfix-for-amavisd">Add new alias virusalert in Postfix for Amavisd</a></li>
</ul>
</li>
<li><a href="#openldap-backend-special">OpenLDAP backend special</a><ul>
<li><a href="#fix-incorrect-ldap-query-filter-in-postfix">Fix incorrect LDAP query filter in Postfix</a><ul>
<li><a href="#use-the-latest-ldap-schema-file-provided-by-iredmail">Use the latest LDAP schema file provided by iRedMail</a></li>
<li><a href="#update-existing-accounts">Update existing accounts</a></li>
<li><a href="#fix-incorrect-ldap-query-filter-in-postfix_1">Fix incorrect LDAP query filter in Postfix</a></li>
</ul>
</li>
<li><a href="#supports-alias-domains-in-postfix-per-user-bcc-lookup-files">Supports alias domains in Postfix per-user bcc lookup files</a></li>
<li><a href="#create-additional-sql-index-for-amavisd-database">Create additional SQL index for Amavisd database</a></li>
</ul>
</li>
<li><a href="#mysql-backend-special">MySQL backend special</a><ul>
<li><a href="#add-4-new-columns-used-for-per-user-restriction">Add 4 new columns used for per-user restriction</a></li>
<li><a href="#create-additional-sql-index-for-amavisd-database_1">Create additional SQL index for Amavisd database</a></li>
</ul>
</li>
<li><a href="#postgresql-backend-special">PostgreSQL backend special</a><ul>
<li><a href="#add-4-new-columns-used-for-per-user-restriction_1">Add 4 new columns used for per-user restriction</a></li>
<li><a href="#create-additional-sql-index-for-amavisd-database_2">Create additional SQL index for Amavisd database</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="admonition note">
<p class="admonition-title">Remote Upgrade Assistance</p>
<p>Check out our <a href="https://www.iredmail.org/support.html">remote upgrade support</a> if you need assistance.</p>
</div>
<h2 id="changelog">ChangeLog</h2>
<ul>
<li>2013-03-28: Update /etc/iredmail-release with iRedMail version number.</li>
<li>2013-03-28: Upgrade Roundcube webmail to the latest 0.8.6.</li>
<li>2013-03-25: [ldap] Fix incorrect LDAP query filter in Postfix.</li>
<li>2013-01-08: [sql] Add 4 new columns in table <code>vmail.mailbox</code> for MySQL/PostgreSQL backends.</li>
<li>2012-10-24: [ldap] Supports alias domains in Postfix per-user bcc lookup files.</li>
</ul>
<h2 id="general-all-backends-should-apply-these-steps">General (All backends should apply these steps)</h2>
<h3 id="update-etciredmail-release-with-iredmail-version-number">Update /etc/iredmail-release with iRedMail version number</h3>
<p>iRedMail stores the release version in <code>/etc/iredmail-release</code> after
installation, it's recommended to update this file after you upgraded iRedMail,
so that you can know which version of iRedMail you're running. For example:</p>
<pre><code># File: /etc/iredmail-release

0.8.4
</code></pre>
<h3 id="upgrade-roundcube-webmail-to-the-latest-stable-release">Upgrade Roundcube webmail to the latest stable release</h3>
<p>Please follow Roundcube official tutorial to upgrade Roundcube webmail to the
latest stable release immediately: <a href="https://github.com/roundcube/roundcubemail/wiki/Upgrade">How to upgrade Roundcube</a>.</p>
<h3 id="upgrade-iredapd-postfix-policy-server-to-the-latest-stable-release">Upgrade iRedAPD (Postfix policy server) to the latest stable release</h3>
<p>Please follow below tutorial to upgrade iRedAPD to the latest stable release:
<a href="./upgrade.iredapd.html">Upgrade iRedAPD to the latest stable release</a></p>
<h3 id="upgrade-iredadmin-open-source-edition-to-the-latest-stable-release">Upgrade iRedAdmin (open source edition) to the latest stable release</h3>
<p>Please follow this tutorial to upgrade iRedAdmin open source edition to the
latest stable release: <a href="./migrate.or.upgrade.iredadmin.html">Upgrade iRedAdmin to the latest stable release</a></p>
<h3 id="add-new-alias-virusalert-in-postfix-for-amavisd">Add new alias <code>virusalert</code> in Postfix for Amavisd</h3>
<p>Amavisd will send an email notification to address <code>virusalert@[YOUR_HOSTNAME]</code>
by default, but we don't have this user in Postfix alias file
<code>/etc/postfix/aliases</code> (on Linux/OpenBSD), or /usr/local/etc/postfix/aliases
(on FreeBSD) or SQL/LDAP database, so emails cannot be delivered. Below steps
add an alias in Postfix alias file, and it will be forwarded to root user by
default.</p>
<p>Add new alias (Note, use '/usr/local/etc/postfix/aliases' on FreeBSD instead),
and update the database:</p>
<pre><code># echo 'virusalert: root' &gt;&gt; /etc/postfix/aliases
# postalias /etc/postfix/aliases
</code></pre>
<h2 id="openldap-backend-special">OpenLDAP backend special</h2>
<h3 id="fix-incorrect-ldap-query-filter-in-postfix">Fix incorrect LDAP query filter in Postfix</h3>
<p>If you add external email addresses as mail list members, iRedAdmin-Pro will
store them in attribute <code>memberOfGroup</code>, this will cause exported LDIF data
cannot be restored. Below are steps to fix this issue.</p>
<p>To fix this issue, we need the latest LDAP schema file provided by iRedMail.
Steps are:</p>
<ul>
<li>Download the newest iRedMail ldap schema file</li>
<li>Copy old ldap schema file as a backup copy</li>
<li>Replace the old one</li>
<li>Restart OpenLDAP service.</li>
</ul>
<p>Here we go:</p>
<h4 id="use-the-latest-ldap-schema-file-provided-by-iredmail">Use the latest LDAP schema file provided by iRedMail</h4>
<ul>
<li>On RHEL/CentOS/Scientific Linux (both release 5.x and 6.x), openSUSE, Gentoo, OpenBSD:</li>
</ul>
<pre><code># cd /tmp
# wget https://github.com/iredmail/iRedMail/raw/1.0/samples/iredmail/iredmail.schema

# cd /etc/openldap/schema/
# cp iredmail.schema iredmail.schema.bak

# cp -f /tmp/iredmail.schema /etc/openldap/schema/
# /etc/init.d/slapd restart       # &lt;-- Or: /etc/init.d/ldap restart
</code></pre>
<ul>
<li>On Debian/Ubuntu:</li>
</ul>
<pre><code># cd /tmp
# wget https://github.com/iredmail/iRedMail/raw/1.0/samples/iredmail/iredmail.schema

# cd /etc/ldap/schema/
# cp iredmail.schema iredmail.schema.bak

# cp -f /tmp/iredmail.schema /etc/ldap/schema/
# /etc/init.d/slapd restart
</code></pre>
<ul>
<li>On FreeBSD:</li>
</ul>
<pre><code># cd /tmp
# wget https://github.com/iredmail/iRedMail/raw/1.0/samples/iredmail/iredmail.schema

# cd /usr/local/etc/openldap/schema/
# cp iredmail.schema iredmail.schema.bak

# cp -f /tmp/iredmail.schema /usr/local/etc/openldap/schema/
# service slapd restart
</code></pre>
<h4 id="update-existing-accounts">Update existing accounts</h4>
<ul>
<li>Download python script used to adding missing values.</li>
</ul>
<pre><code># cd /root/
# wget https://github.com/iredmail/iRedMail/raw/1.0/update/ldap/updateLDAPValues_083_to_084.py
</code></pre>
<p>Open downloaded file <code>updateLDAPValues_083_to_084.py</code>, set LDAP server related
settings in file head. for example,</p>
<pre><code># Part of file: updateLDAPValues_083_to_084.py

uri = 'ldap://127.0.0.1:389'
basedn = 'o=domains,dc=example,dc=com'
bind_dn = 'cn=vmailadmin,dc=example,dc=com'
bind_pw = 'passwd'
</code></pre>
<p>You can find required LDAP credential in iRedAdmin config file or <code>iRedMail.tips</code>
file under your iRedMail installation directory. Using either
<code>cn=Manager,dc=xx,dc=xx</code> or <code>cn=vmailadmin,dc=xx,dc=xx</code> as bind dn is ok.</p>
<p>Execute this script, it will fix incorrect values and add correct ones:</p>
<pre><code># python updateLDAPValues_083_to_084.py
</code></pre>
<h4 id="fix-incorrect-ldap-query-filter-in-postfix_1">Fix incorrect LDAP query filter in Postfix</h4>
<ul>
<li>On Linux/OpenBSD, please update <code>/etc/postfix/ldap/virtual_group_maps.cf</code>.
  On FreeBSD, update <code>/usr/local/etc/postfix/ldap/virtual_group_maps.cf</code> instead.</li>
</ul>
<pre><code># Part of file: ldap/virtual_group_maps.cf

# OLD setting
#query_filter    = (&amp;(memberOfGroup=%s)(accountStatus=active)(enabledService=mail)(enabledService=deliver)(|(objectClass=mailUser)(objectClass=mailExternalUser)))

# New setting
query_filter    = (&amp;(accountStatus=active)(enabledService=mail)(enabledService=deliver)(|(memberOfGroup=%s)(shadowAddress=%s))(|(objectClass=mailUser)(objectClass=mailExternalUser)))
</code></pre>
<p>Restarting Postfix service is required.</p>
<h3 id="supports-alias-domains-in-postfix-per-user-bcc-lookup-files">Supports alias domains in Postfix per-user bcc lookup files</h3>
<ul>
<li>In <code>/etc/postfix/ldap/sender_bcc_maps_user.cf</code>, replace <code>(mail=%s)</code> by
  <code>(|(mail=%s)(&amp;(enabledService=shadowaddress)(shadowAddress=%s)))</code> in parameter
  <code>query_filter =</code>. The final LDAP filter looks like below:</li>
</ul>
<pre><code># Part of file: ldap/sender_bcc_maps_user.cf

query_filter    = (&amp;(|(mail=%s)(&amp;(enabledService=shadowaddress)(shadowAddress=%s)))(objectClass=mailUser)(accountStatus=active)(enabledService=mail)(enabledService=senderbcc))
</code></pre>
<ul>
<li>Perform the same modification in file <code>/etc/postfix/ldap/recipient_bcc_maps_user.cf</code>,
  the final LDAP filter looks like below:</li>
</ul>
<pre><code># Part of file: ldap/recipient_bcc_maps_user.cf

query_filter    = (&amp;(|(mail=%s)(&amp;(enabledService=shadowaddress)(shadowAddress=%s)))(objectClass=mailUser)(accountStatus=active)(enabledService=mail)(enabledService=recipientbcc))
</code></pre>
<p>Restarting Postfix service is required.</p>
<h3 id="create-additional-sql-index-for-amavisd-database">Create additional SQL index for Amavisd database</h3>
<p>We need one new SQL index for Amavisd database, it's used to speed up
performance of viewing quarantined mails.</p>
<p><strong>Note</strong>: It may take long time if you have many records in sql table <code>amavisd.msgs</code>.</p>
<pre><code>$ mysql -uroot -p
mysql&gt; USE amavisd;
mysql&gt; ALTER TABLE msgs ADD INDEX (quar_type);
</code></pre>
<h2 id="mysql-backend-special">MySQL backend special</h2>
<h3 id="add-4-new-columns-used-for-per-user-restriction">Add 4 new columns used for per-user restriction</h3>
<p>New version of iRedAPD (Postfix policy daemon) requires 4 new columns in table
<code>vmail.mailbox</code>:</p>
<ul>
<li>allowedsenders</li>
<li>rejectedsenders</li>
<li>allowedrecipients</li>
<li>rejectedrecipients</li>
</ul>
<p>They're used for per-user restriction. For example, you can now define who can
send email to your local user, or your user can send email to which external
domains or users.</p>
<p>Please login to MySQL server as root user, execute SQL commands to add required
columns and indexes.</p>
<pre><code># mysql -uroot -p
mysql&gt; USE vmail;
mysql&gt; ALTER TABLE mailbox ADD COLUMN allowedsenders TEXT NOT NULL DEFAULT '';
mysql&gt; ALTER TABLE mailbox ADD COLUMN rejectedsenders TEXT NOT NULL DEFAULT '';
mysql&gt; ALTER TABLE mailbox ADD COLUMN allowedrecipients TEXT NOT NULL DEFAULT '';
mysql&gt; ALTER TABLE mailbox ADD COLUMN rejectedrecipients TEXT NOT NULL DEFAULT '';
</code></pre>
<p>Supported formats of sender/recipients are:</p>
<ul>
<li><code>user@example.com</code>: single user</li>
<li><code>@example.com</code>: entire domain</li>
<li><code>@.example.com</code>: entire domain and all its sub domains</li>
<li><code>@.</code>: any users</li>
</ul>
<p>Multiple senders/recipients must be separated by comma, for example:</p>
<pre><code>sql&gt; INSERT INTO mailbox SET allowedsenders='@gmail.com,user@example.com';
</code></pre>
<h3 id="create-additional-sql-index-for-amavisd-database_1">Create additional SQL index for Amavisd database</h3>
<p>We need one new SQL index for Amavisd database, it's used to speed up
performance of viewing quarantined mails.</p>
<p><strong>Note</strong>: It may take long time if you have many records in sql table <code>amavisd.msgs</code>.</p>
<pre><code>$ mysql -uroot -p
mysql&gt; USE amavisd;
mysql&gt; ALTER TABLE msgs ADD INDEX (quar_type);
</code></pre>
<h2 id="postgresql-backend-special">PostgreSQL backend special</h2>
<h3 id="add-4-new-columns-used-for-per-user-restriction_1">Add 4 new columns used for per-user restriction</h3>
<p>New version of iRedAPD (Postfix policy daemon) requires 4 new columns in table
<code>vmail.mailbox</code>:</p>
<ul>
<li>allowedsenders</li>
<li>rejectedsenders</li>
<li>allowedrecipients</li>
<li>rejectedrecipients</li>
</ul>
<p>They're used for per-user restriction. For example, you can now define who can
send email to your local user, or your user can send email to which external
domains or users.</p>
<p>Please switch to PostgreSQL daemon user, then execute SQL commands to add
required new columns and indexes:</p>
<ul>
<li>On Linux, PostgreSQL daemon user is <code>postgres</code>.</li>
<li>On FreeBSD, PostgreSQL daemon user is <code>pgsql</code>.</li>
<li>On OpenBSD, PostgreSQL daemon user is <code>_postgresql</code>.</li>
</ul>
<pre><code># su - postgres
$ psql -d vmail
sql&gt; ALTER TABLE mailbox ADD COLUMN allowedsenders TEXT NOT NULL DEFAULT '';
sql&gt; ALTER TABLE mailbox ADD COLUMN rejectedsenders TEXT NOT NULL DEFAULT '';
sql&gt; ALTER TABLE mailbox ADD COLUMN allowedrecipients TEXT NOT NULL DEFAULT '';
sql&gt; ALTER TABLE mailbox ADD COLUMN rejectedrecipients TEXT NOT NULL DEFAULT '';
</code></pre>
<p>Supported formats of sender/recipients are:</p>
<ul>
<li><code>user@example.com</code>: single user</li>
<li><code>@example.com</code>: entire domain</li>
<li><code>@.example.com</code>: entire domain and all its sub domains</li>
<li><code>@.</code>: any users</li>
</ul>
<p>Multiple senders/recipients must be separated by comma, for example:</p>
<pre><code>sql&gt; INSERT INTO mailbox SET allowedsenders='@gmail.com,user@example.com';
</code></pre>
<h3 id="create-additional-sql-index-for-amavisd-database_2">Create additional SQL index for Amavisd database</h3>
<p>We need one new SQL index for Amavisd database, it's used to speed up
performance of viewing quarantined mails.</p>
<p><strong>Note</strong>: It may take long time if you have many records in sql table <code>amavisd.msgs</code>.</p>
<p>Please switch to PostgreSQL daemon user, then execute SQL commands to add required columns and indexes:</p>
<ul>
<li>On Linux, PostgreSQL daemon user is <code>postgres</code>.</li>
<li>On FreeBSD, PostgreSQL daemon user is <code>pgsql</code>.</li>
<li>On OpenBSD, PostgreSQL daemon user is <code>_postgresql</code>.</li>
</ul>
<pre><code># su - postgres
$ psql -d amavisd
sql&gt; CREATE INDEX idx_msgs_quar_type ON msgs (quar_type);
</code></pre><div class="footer">
    <p style="text-align: center; color: grey;">All documents are available in <a href="https://github.com/iredmail/docs/">GitHub repository</a>, and published under <a href="http://creativecommons.org/licenses/by-nd/3.0/us/" target="_blank">Creative Commons</a> license. You can <a href="https://github.com/iredmail/docs/archive/master.zip">download the latest version</a> for offline reading. If you found something wrong, please do <a href="https://www.iredmail.org/contact.html">contact us</a> to fix it.</p>
</div></body></html>